#使用方法 a.sh 文件名称 要创建的位置（可不选 默认根目录）
文件
for file in $(ls)
do
  if [ $file == $1 ];then
      echo $1 "目录已存在"
      exit
  fi
done

if [ -n "$2" ]; then
 directory=$2
 rep="/"
 directory=${directory//\\/$rep}
 directory=${directory/:/}
 directory="/"$directory
 cd $directory
fi

mkdir $1
cd $1
#生成 lcss
echo "" > $1.less
echo '' > $1.less



# 生成 vue
echo "" > $1.vue
echo '<template>
  <div class="page-container">
    '$1'
  </div>
</template>

<script>
  import '$1' 'from "'./$1.js'"'

  export default '$1';
</script>

<style scoped lang="less">
  @import "./'$1'.less";
</style>' > $1.vue

# 生成 js
echo "" > $1.js
echo '
import {onBeforeUnmount, onMounted, reactive, ref} from "vue";
export default {
  name:"'$1'",
  setup(props, {attrs, slots}) {

    onMounted(()=>{
      console.log("onMounted")
    });

    onBeforeUnmount(()=>{
      console.log("onBeforeUnmount")
    });
    return {};
  }
}
' > $1.js
